package com.hujf.mapreduce.outputformat;

import com.hujf.mapreduce.wordcount.mapper.WordCountMapper;
import com.hujf.mapreduce.wordcount.reduce.WordCountReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @author Hujf
 * @title: LogDriver
 * @date 2021/4/110:23
 * @description: TODO
 */
public class LogDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //1.获得job
        Job job = Job.getInstance(new Configuration());

        job.setJarByClass(LogDriver.class);

        //3.关联mapper和reduce
        job.setMapperClass(LogMapper.class);
        job.setReducerClass(LogReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        job.setOutputFormatClass(LogOutputFormat.class);

        FileInputFormat.setInputPaths(job,new Path("F:\\hbase\\data\\input\\www"));
        FileOutputFormat.setOutputPath(job,new Path("F:\\hbase\\data\\logs"));

        job.waitForCompletion(true);
    }
}
